package com.sztz.mapstruct.C字段不同名转换;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * CarMapper
 *
 * @author yyf
 * @email yeyafei@hotmail.com
 */
@Mapper
public interface CarMapper {


    CarMapper INSTANCE = Mappers.getMapper(CarMapper.class);

    /**
     * filed不同名拷贝
     * 拷贝指定属性，其余拷贝同名属性
     *
     * @param car
     * @return CarDto
     */
    @Mapping(source = "owner", target = "ownerName")
    CarDTO toDto(Car car);

    /**
     * 多Mapping
     *
     * @param car
     * @return CarDTO
     */
    @Mappings({
            @Mapping(source = "owner", target = "ownerName"),
            @Mapping(source = "age", target = "ownerAge")
    })
    CarDTO toDto2(Car car);
}
